<template>
  <div>正在登陆...</div>
</template>
<script>
import { ssologin } from '@/api/user.js'

export default {
  name: 'home',
  data() {
    return {
      params: {
        state: '',
        code: ''
      }
    }
  },
  mounted() {
    if (this.$route.query) {
      this.params.state = this.$route.query.state
      this.params.code = this.$route.query.code
      this.ssologin(this.params)
    }
  },
  methods: {
    // 单点登陆
    ssologin(params) {
      ssologin(params, res => {
        if (res && res.hasOwnProperty('accessToken')) {
          sessionStorage.setItem('token', res.accessToken)
          this.$router.push('spider_list')
        } else {
          this.$router.push('/')
        }
      }, err => {

      })
    }
  }

}
</script>
